<template>
  <div class="app-container jklis">
    <div class="zdy-main">
      <!-- <el-form ref="queryForm" :inline="true" class="zdy-form search-form-new" label-width="68px">
        <el-form-item>
          <el-button icon="el-icon-plus" type="primary" size="mini" @click="addACount"
            class="zdy-btn zdy-btn-refresh">新增模板</el-button>
        </el-form-item>
      </el-form> -->
      <el-table :data="tableData.records"  style="width: 100%">
        <el-table-column label="序号" prop="id" width="50"> </el-table-column>
        <el-table-column label="模板类型" prop="type" >
          <template slot-scope="scope">
            <div>
              {{typeMap[scope.row.type]}}
            </div>
          </template>
        </el-table-column>
        <el-table-column label="合同名称" prop="signTaskSubject"> </el-table-column>
        <el-table-column label="合同ID" prop="signTaskId" />
        <el-table-column label="状态" prop="status" width="100">
          <template slot-scope="scope">
            <div>
            <span v-show="scope.row.status==1" style="color: chocolate;">签署中 </span>
            <span v-show="scope.row.status==2" style="color: forestgreen;">签署完成 </span>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="发起方" prop="initiator" />
        <el-table-column label="甲方" prop="purchaserName" />
        <el-table-column label="乙方" prop="sellerName" />
        <el-table-column label="业务ID" prop="businessId" />
        <el-table-column label="签署完成时间" prop="completionTime" />
        <el-table-column label="操作" width="200">
          <template slot-scope="scope">
            <el-button type="text" size="mini" @click="viewModel(scope.row)">查看</el-button>
          
          </template>
        </el-table-column>
      </el-table>
      <div class="pages-box">
        <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
          :current-page="queryParams.pageNum" :page-sizes="[1,10, 20, 30, 40, 50, 60]" :page-size="queryParams.pageSize"
          layout="total, sizes, prev, pager, next, jumper" :total="tableData.total"></el-pagination>
      </div>

    </div>
  </div>
</template>

<script>
import fadadaApi from "../../api/B2Cmanage/fadada"
export default {
  name: "financial",
  components: {},
  data() {
    return {
      tableData: {
        records: [],
        total: 0
      },
      queryParams: {
        pageSize: 10,
        pageNum: 1
      },
      typeMap: 
        {
          0: "未启用",
          1: "订单三方协议",
          2: "购买协议",
          3: "卖方协议",
          4: "商家入驻协议",
        },
      loading: false,
    };
  },
  created() {
    this.getList();
    // this.getTypeList();
  },
  activated() {
    this.getList();
  },
  methods: {
    // 获取列表
    getList() {
      this.tableData.records = [];
      this.loading = true;
      let obj = this.queryParams
      fadadaApi
        .fddContractList(obj)
        .then(response => {
          // console.log("%c Line:111 🥑 response", "color:#42b983", response);
          this.$nextTick(() => {
            this.loading = false;
            this.tableData.records = response.rows
            this.tableData.total = response.total;
          });
        })
        .catch(err => {
          this.loading = false;
        });
    },
    // 新增
    // addACount() {
    //   fadadaApi.getAddModelUrl().then(res => {
    //     console.log("%c Line:110 🎂 res", "color:#b03734", res);
    //     if (res.code == 200) {
    //       window.open(res.msg)
    //     }
    //   })
    // },
    // 查看
    viewModel(row) {
      // 查看详情
      let obj = {
        signTaskId: row.signTaskId
      }
      fadadaApi.reviewContractDetail(obj).then(res => {
        // console.log("%c Line:110 🎂 res", "color:#b03734", res);
        if (res.code == 200) {
          window.open(res.msg)
        }
      })
    },
    // 删除记录
    delItem(row) {
      this.$confirm("此操作将永久删除该记录, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          appApi.del(row.id).then(res => {
            this.$message({
              type: "success",
              message: "删除成功!"
            });
            this.getList()
          });
        })
        .catch(() => { });
    },
    // 每页条数改变
    handleSizeChange(val) {
      this.queryParams.pageSize = val;
      this.getList();
    },
    // 页码改变
    handleCurrentChange(val) {
      this.queryParams.pageNum = val;
      this.getList();
    }

  }
};
</script>
<style lang="scss" scoped>
.model-cont-item {
  border-bottom: 1px solid #ccc;
}
</style>
